using M13.DataStructure;
using M13.Utility.Registrar;
using System.Collections.Generic;
using M13.Game.Item.Food;
using M13.Game.Item.Weapon;
using UnityEngine;

namespace M13.Game.Item
{
    public class Items
    {
        private static List<Item> _itemFields = new List<Item>();

        private static UniqueIdDictionary<int, string> _idKeyValues = new UniqueIdDictionary<int, string>();

        

        public static Item Cudgel { get; private set; } = WeaponRegistrar<Cudgel>.Registered(
            0, "cudgel", ItemType.Weapon, 1, ResourceKey.ItemSprites.Cudgel, ResourceKey.ItemModals.Cudgel,
            3, 1, 32, WeaponConfigs.CudgelConfig,
            _itemFields, _idKeyValues
            );

        public static Item Stick { get; private set; } = ItemRegistrar<Item>.Register(
            1, "stick", ItemType.Item, 32, ResourceKey.ItemSprites.Stick, ResourceKey.ItemModals.Stick,
            _itemFields, _idKeyValues
            );
        

        public static Item Apple { get; private set; } = ItemRegistrar<Fruit>.Register(
            2, "apple", ItemType.Food, 16, ResourceKey.ItemSprites.Apple, ResourceKey.ItemModals.Apple,
            _itemFields, _idKeyValues
            );

        


        public static Item GetItemIntance(int id)
        {
            for(int i = 0; i < _itemFields.Count; i++)
            {
                if (id > -1 && _itemFields[id] != null)
                {
                    if (_itemFields[i].ItemProperties.Id == id)
                        return _itemFields[i];
                }
            }
            return null;
        }
    }
}
